package com.wyman.factory.config;

import com.wyman.PropertyValues;

/**
 * @Author 李伟民
 * @Description DateTime 2024/11/25 01:42
 */
public class BeanDefinition {

    String SCOPE_SINGLETON = ConfigurableBeanFactory.SCOPE_SINGLETON;
    String SCOPE_PROTOTYPE = ConfigurableBeanFactory.SCOPE_PROTOTYPE;

    private Class beanClass;
    //增加bean的属性信息
    private PropertyValues propertyValues;

    //12.12 7. 熙增初始化方法和销毁方法
    private String initMethodName;

    private String destroyMethodName;

    //默认使用单例模式
    private boolean singleton = true;
    private boolean prototype = false;
    private String scope = SCOPE_SINGLETON;

    public BeanDefinition(Class beanClass){
        this.beanClass = beanClass;
        this.propertyValues = new PropertyValues();
    }

    public BeanDefinition(Class beanClass,PropertyValues propertyValues){
        this.beanClass = beanClass;
        this.propertyValues =propertyValues;
    }

    public Class getBeanClass(){

        return beanClass;
    }
    public void setBeanClass(Class beanClass){
        this.beanClass = beanClass;

    }

    public PropertyValues getPropertyValues() {
        return propertyValues;
    }

    public void setPropertyValues(PropertyValues propertyValues) {
        this.propertyValues = propertyValues;
    }

    public void setDestroyMethodName(String destroyMethodName) {
        this.destroyMethodName = destroyMethodName;
    }

    public void setInitMethodName(String initMethodName) {
        this.initMethodName = initMethodName;
    }

    public String getDestroyMethodName() {
        return destroyMethodName;
    }

    public String getInitMethodName() {
        return initMethodName;
    }

    public void setScope(String scope){
        this.scope = scope;
        this.singleton = SCOPE_SINGLETON.equals(this.scope)?true:false;
        this.prototype = SCOPE_PROTOTYPE.equals(this.scope)?true:false;
    }

    public boolean isSingleton() {
        return singleton;
    }

    public boolean isPrototype() {
        return prototype;
    }
}
